import 'package:flutter_axrjc/datasource/network/api/UserApi.dart';
import 'package:flutter_axrjc/routes.dart';
import 'package:get/get.dart';

import 'state.dart';

class SplashLogic extends GetxController {
  final SplashState state = SplashState();
  @override
  void onInit() {
    super.onInit();
    check();
  }

  Future<void> check() async {
    var user = await UserApi.getUser();
    if (user == null) {
      Get.offNamed(MainRoutes.login, arguments: FormType.splash);
    } else {
      // UserApi.login(phone: "${user.customerInfo?.telPhone}", password: password)
      Get.offNamed(MainRoutes.main);
    }
  }
}

enum FormType {
  splash,
  other,
}
